﻿#ifndef ITEMADD_H
#define ITEMADD_H

#include "optioneditor.h"
#include "support/sp_env.h"
#include "head/g_functionbase.h"

class ItemAdd : public QDialog
{
public:
    explicit ItemAdd(QWidget *parent = 0): QDialog(parent)
    {
        optionTable = TD_OPTIONS;
        status = ST_WAIT;
    }

    virtual bool addItem()
    {
        return true;
    }

    virtual void reload(){}

    void sendMsg(const QString &title,const QString &content)
    {
        QByteArray data;
        QDataStream out(&data,QIODevice::WriteOnly);
        out << title << content ;

        sp_sendData(data,"192.168.1.255",quint16(SEND_PORT));
    }

    QStringList getOptions(const QString &type)
    {
        QStringList list;
        QSqlQuery query;
        query.exec(QString("select label from %1 where type='%2'").arg(optionTable).arg(type));
        while(query.next())
            list.append(query.value(0).toString());

        return list;
    }

protected:
    QString table;

    QString optionTable;
    QString status;
};

#endif // ITEMADD_H
